
//将html数据保存到gridPanel
function pasteToGridPanel(html, gridPanel, idKey, toSetColumnArray) {
	var datas = trunHtmlToDatas(html,idKey);
	var columnsMap = getColumnsMap(gridPanel);
	console.log(columnsMap);
	
	for(var i=0;i<datas.length;i++){
		var data = datas[i];
		var record = dataStore.findRecord(columnsMap["key_"+idKey], data["key_"+idKey]);
		if(record){
			for(var j=0;j<toSetColumnArray.length;j++){
				var text = toSetColumnArray[j];
				var val = data["key_"+text];
				if(val){
					record.set(columnsMap["key_"+text] , val);
				}
			}
			//record.commit();
		}
	}
}
//将表格中的列,转为map,方便查找
function getColumnsMap(gridPanel){
	var columnsMap = {};
	for(var i=0;i<gridPanel.columns.length;i++){
		var column = gridPanel.columns[i];
		columnsMap["key_"+column.text.replace('<span class="blue">','').replace('<span class="red">','').replace('</span>','')] = column.dataIndex;
	}	
	return columnsMap;
}

//将html转为json数据,取idKey为表头
function trunHtmlToDatas(html,idKey){
	var datas = [];
	var lines = html.split("\n");
	var heads = lines[0].split("\t");
	
	for(var i=1;i<lines.length;i++){
		var data = {};
		var words = lines[i].split("\t");
		for(var j=0;j<words.length;j++){
			data["key_"+heads[j]] = words[j];
		}
		datas.push(data);
	}
	return datas;
}
//获取excel提取列
function getExcelColumnArray(list,name){
	var columnNames = [];
	for(var i=0;i<list.length;i++){
		columnNames.push(list[i].name);
	}
	return columnNames;
}